<?php

abstract class  Pattern {
	
	public $pattern;
	public $action;
	
	public function replace($text){
		return preg_replace_callback($this->pattern,$this->action,$text);
	}//end replace
	
	public function  setAction(callable $action){
		$this->action = $action;
		return $this;
	}//end setAction
	
	public function matchAll($text){
		preg_match_all($this->pattern,$text,$matches, PREG_PATTERN_ORDER);
		array_unshift($matches, null);
		return  call_user_func_array('array_map', $matches);
	}//matchAll
}
?>